
import {WL} from './weilapb';
import {WLBuildMsgRet} from './weilapb_wrapper_data';
import {BuildWeilaMsg} from './weilapb_wrapper';
import Long from 'long';

class WeilaPbGroupWrapper {
    public static buildGetGroupVersionReq(): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupVersion = new WL.Group.ReqGetGroupVersion();
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_GROUPVERSION,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetGroupAttributeReq(type: number, key: string, classType: number, groupId: Long, pageIndex: number, pageSize: number): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupAttribute = new WL.Group.ReqGetGroupAttribute();
        groupMessage.reqGetGroupAttribute.type = type;
        groupMessage.reqGetGroupAttribute.key = key;
        groupMessage.reqGetGroupAttribute.class = classType;
        groupMessage.reqGetGroupAttribute.groupId = groupId;
        groupMessage.reqGetGroupAttribute.pageIndex = pageIndex;
        groupMessage.reqGetGroupAttribute.pageSize = pageSize;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_GROUPATTRIBUTE,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetMemberUserInfoReq(groupId: Long, userIdList: number[]): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetMemberUserInfo = new WL.Group.ReqGetMemberUserInfo();
        groupMessage.reqGetMemberUserInfo.groupId = groupId;
        groupMessage.reqGetMemberUserInfo.userIdList = userIdList;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_MEMBER_USERINFO,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetGroupInviteInfoReq(latestUpdated: number): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupInviteInfo = new WL.Group.ReqGetGroupInviteInfo();
        groupMessage.reqGetGroupInviteInfo.latestUpdated = Long.fromValue(latestUpdated);
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_GROUP_INVITEINFO,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetGroupJoinInfoReq(latestUpdated: number, groupIds: Long[]): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupJoinInfo = new WL.Group.ReqGetGroupJoinInfo();
        groupMessage.reqGetGroupJoinInfo.latestUpdated = Long.fromValue(latestUpdated);
        groupMessage.reqGetGroupJoinInfo.groupIds = groupIds;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_GROUP_JOININFO,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetGroupOnlineMemberReq(groupId: Long): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupOnlineMember = new WL.Group.ReqGetGroupOnlineMember();
        groupMessage.reqGetGroupOnlineMember.groupId = groupId;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_ONLINE_MEMBER,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetGroupInfoReq(groupId: Long, memberVersion: number): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupInfo = new WL.Group.ReqGetGroupInfo();
        groupMessage.reqGetGroupInfo.groupId = groupId;
        groupMessage.reqGetGroupInfo.memberVersion = memberVersion;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_GROUPINFO,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }
    
    public static buildGetGroupBlackListReq(groupId: Long, pageIndex: number, pageSize: number): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupBlackList = new WL.Group.ReqGetGroupBlackList();
        groupMessage.reqGetGroupBlackList.groupId = groupId;
        groupMessage.reqGetGroupBlackList.pageIndex = pageIndex;
        groupMessage.reqGetGroupBlackList.pageSize = pageSize;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_BLACKLIST,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetGroupMemberChangeLogReq(groupId: Long): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupMemberChangeLog = new WL.Group.ReqGetGroupMemberChangeLog();
        groupMessage.reqGetGroupMemberChangeLog.groupId = groupId;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_MEMBER_CHANGE_LOG,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }
    
    public static buildGetGroupDetailReq(groupId: Long): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetGroupDetail = new WL.Group.ReqGetGroupDetail();
        groupMessage.reqGetGroupDetail.groupId = groupId;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_GROUPDETAIL,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }

    public static buildGetSubGroupAttributeReq(): WLBuildMsgRet {
        const groupMessage = new WL.Group.GroupMessage();
        groupMessage.reqGetSubGroupAttribute = new WL.Group.ReqGetSubGroupAttribute();
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_GROUP,
            WL.Group.GroupCommandId.GROUP_COMMAND_GET_SUB_GROUPATTRIBUTE,
            WL.Service.CommandType.COMMAND_REQUEST, groupMessage);
    }
}

export {WeilaPbGroupWrapper}